<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //模拟计算器
        var num = prompt('请输入第一个数字') - 0; //隐形转换成number类型
        var num2 = prompt('请输入+-*/');
        var num1 = prompt('请输入第二个数字') - 0;
        var sum = 0;
        switch (num2) {
            case '+':
                sum = num + num1;
                alert('两个数之和' + sum);
                break;
            case '-':
                sum = num - num1;
                alert('两个数之差' + sum);
                break;
            case '*':
                sum = num * num1;
                alert('两个数之积' + sum);
                break;
            case '/':
                sum = num / num1;
                alert('两个数之除' + sum);
                break;
            default:
                alert('请输入正确的数字或符号');

        }
    </script>


</body>

</html>